﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.Serialization;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Store.Web.Models
{
    [DataContract]
    public class Product
    {
        [DataMember]
        [HiddenInput]
        public int Id { get; set; }

        [DataMember]
        [DataType(DataType.Text)]
        [StringLength(250)]
        public string Title { get; set; }

        [DataMember]
        [DataType(DataType.MultilineText)]
        [StringLength(1000)]
        public string Description { get; set; }

        [DataMember]
        [DataType(DataType.Url)]
        [StringLength(255)]
        public string PictureUrl { get; set; }

        [DataMember]
        [DataType(DataType.Text)]
        public decimal Price { get; set; }

        #region public override

        public override bool Equals(object obj)
        {
            bool areEquals = false;

            Product currentItem = this;
            Product compared = obj as Product;

            if (this == null && obj == null)
            {
                areEquals = true;
            }
            else if (obj != null && compared != null)
            {
                if (currentItem.Id == compared.Id)
                {
                    areEquals = true;
                }
            }
            return areEquals;
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }

        #endregion
    }
}